import java.sql.SQLOutput;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 蒋健
 * Date: 2022-01-23
 * Time: 9:09
 */
public class TestDemo {
    public static void main(String[] args) {
        MyQueue queue =new MyQueue();
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        System.out.println(queue.peek());//1
        System.out.println(queue.poll());//1
        System.out.println(queue.poll());//2
        System.out.println(queue.poll());//3
    }

//    public static void main(String[] args) {
//        Deque<Integer> deque =new LinkedList<>();
//        deque.offer(1);//默认从队尾入队的
//        deque.offerFirst(2);
//        System.out.println(deque.peek());
//    }

//    public static void main(String[] args) {
//        Queue<Integer> queue =new LinkedList<>();
//        queue.offer(1);
//        queue.offer(2);
//        queue.offer(3);
//        queue.offer(4);
//        System.out.println(queue.peek());
//        System.out.println(queue.peek());
//    }


//    public static void main(String[] args) {
//        Queue<Integer> queue = new LinkedList<>();
//        Deque<Integer> deque = new LinkedList<>();
//
//        LinkedList<Integer> list = new LinkedList<>();
//    }



    private Stack<Integer> stack;
    private Stack<Integer> minStack;




    public boolean isValid(String s) {
        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == '(' || ch == '[' || ch == '{') {
                //如果是左括号直接入栈
                stack.push(ch);
            } else {
                //遇到了右括号
                if (stack.empty()) {
                    System.out.println("右括号多！");
                    return false;//右括号多
                }
                char top = stack.peek();//获取栈顶的左括号
                if(top=='{'&&ch=='}'||top=='['&&ch==']'||top=='('&&ch==')'){
                    stack.pop();
                }else{
                    //左右括号不匹配
                    System.out.println("左右括号不匹配！");
                    return false;
                }
            }
        }
        if (!stack.empty()){
            //左括号多
            System.out.println("左括号多！");
            return false;
        }
        return true;
    }
}
